package com.example.tests;



import org.junit.*;
import static org.junit.Assert.*;

import com.eample.pages.UserPage;

public class BInsEditor extends TestBase {

	@Test
	public void InsEditor() throws Exception {
		UserPage userPage = goToMainPage()
			.LoginWithValidCredentials("admin",	"admin")
			.GotoUserManagement();
		
		SortedListOf<User> oldUserList=userPage.getUsers();
		
		User user =new User()
			.withName("editor").withEmail("editor@test.com").withPassword("editor");
		
		if (oldUserList.contains(user)){
			userPage.deleteUser(user);
			oldUserList=userPage.getUsers();
		}

		userPage.InsUser(user);
		
		SortedListOf<User> newUserList=userPage.getUsers();
		
		assertEquals(newUserList, oldUserList.withAdded(user));

		userPage.logout();

	}

}
